﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataOutbound" @search="()=>{getTableDataOutbound();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SheetId_FormItem" prop="SheetId" :label="$t('message.autotrans._Model_Outbound_SheetId')">
            <el-input v-model="searchDataOutbound.SheetId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SheetNo_FormItem" prop="SheetNo" :label="$t('message.autotrans._Model_Outbound_SheetNo')">
            <el-input v-model="searchDataOutbound.SheetNo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OutMode_FormItem" prop="OutMode" :label="$t('message.autotrans._Model_Outbound_OutMode')">
            <el-select v-model="searchDataOutbound.OutMode" clearable>
               <el-option key="Manual" value="Manual" :label="$t('message.autotrans._Enum_InOutEnum_Manual')"></el-option>
               <el-option key="Sys" value="Sys" :label="$t('message.autotrans._Enum_InOutEnum_Sys')"></el-option>
               <el-option key="Scan" value="Scan" :label="$t('message.autotrans._Enum_InOutEnum_Scan')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Wo_FormItem" prop="Wo" :label="$t('message.autotrans._Model_Outbound_Wo')">
            <el-input v-model="searchDataOutbound.Wo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sn_FormItem" prop="Sn" :label="$t('message.autotrans._Model_Outbound_Sn')">
            <el-input v-model="searchDataOutbound.Sn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MaterialId_FormItem" prop="MaterialId" :label="$t('message.autotrans._Model_Outbound_Material')">
            <el-select v-model="searchDataOutbound.MaterialId" clearable>
               <el-option v-for="item in stateOutbound.AllMaterials" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StoreQty_FormItem" prop="StoreQty" :label="$t('message.autotrans._Model_Outbound_StoreQty')">
            <el-input v-model="searchDataOutbound.StoreQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OutQty_FormItem" prop="OutQty" :label="$t('message.autotrans._Model_Outbound_OutQty')">
            <el-input v-model="searchDataOutbound.OutQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OutOperator_FormItem" prop="OutOperator" :label="$t('message.autotrans._Model_Outbound_OutOperator')">
            <el-input v-model="searchDataOutbound.OutOperator" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OutboundDate_FormItem" prop="OutboundDate" :label="$t('message.autotrans._Model_Outbound_OutboundDate')">
            <el-date-picker v-model="searchDataOutbound.OutboundDate" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/WmsManagement/Outbound/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/WmsManagement/Outbound/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/WmsManagement/Outbound/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/WmsManagement/Outbound/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/WmsManagement/Outbound/OutboundExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefOutbound" v-bind="tableDataOutbound">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/WmsManagement/Outbound/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/WmsManagement/Outbound/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/WmsManagement/Outbound/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageWmsManagementOutboundIndex;true;Digitalmes.WmsManagement.Controllers;Outbound">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { outboundApi } from '/@/api/wmsmanagement/outbound';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateOutbound = reactive({
    
    AllMaterials: [] as any[],
});

const searchDataOutbound = ref({
        SheetId: '',
        SheetNo: '',
        OutMode: undefined,
        Wo: '',
        Sn: '',
        MaterialId: null,
        StoreQty: null,
        OutQty: null,
        OutOperator: '',
        OutboundDate: undefined,
});

// 定义变量内容
const tableRefOutbound = ref();
const tableDataOutbound = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page出库单号'),key: 'Outbound_SheetId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page出库单号'),key: 'Outbound_SheetNo',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page出库方式'),key: 'Outbound_OutMode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page生产工单'),key: 'Outbound_Wo',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page追溯码'),key: 'Outbound_Sn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page物料'),key: 'Outbound_Material',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page在库数量'),key: 'Outbound_StoreQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page出库数量'),key: 'Outbound_OutQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page出库'),key: 'Outbound_OutOperator',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page出库时间'),key: 'Outbound_OutboundDate',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataOutbound = () => {
    tableRefOutbound.value.doSearch(outboundApi().search, searchDataOutbound.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataOutbound)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataOutbound)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataOutbound)
};

// 删除
const onDelete = (row: any) => {
    outboundApi().delete([row.ID]).then(() => { getTableDataOutbound()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefOutbound.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      outboundApi().delete(selectedids).then(() => { getTableDataOutbound()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefOutbound.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataOutbound)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataOutbound)
};

const onExport = () => {
	const selected = tableRefOutbound.value.getSelectedRows();
	if (selected.length > 0) {
		outboundApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		outboundApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/WmsManagement/Outbound/GetMaterialDocs',[],false).then(x=>{stateOutbound.AllMaterials = x});
        getTableDataOutbound();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

